<template>
    <div class="hotMovie">
        <p class="like">
            {{ text }}
        </p>
        <van-tabs v-model="active" background="#EEEEEE">
            <van-tab v-for="v in list" :key="v.id">
                <template #title>
                    <div class="hotMovieItem">
                        <van-image
                            class="hotMovieItem-img"
                            fit="cover"
                            :src="v.imgURL"
                        />
                        <div class="hotMovieItem-mask">
                            <p class="van-ellipsis">{{ v.subhead }}</p>
                            <p class="van-ellipsis">{{ v.subhead }}</p>
                        </div>
                    </div>
                </template>
            </van-tab>
        </van-tabs>
    </div>
</template>

<script>
import { getHotMovie } from '@/api/jia';
export default {
    props: {
        text: {
            type: String,
            default: () => '热门推荐'
        }
    },
    data() {
        return {
            active: 0,
            list: []
        };
    },
    created() {
        this.getHotMovie();
    },
    methods: {
        async getHotMovie() {
            // this.$toast.loading({
            //     message: '加载中...',
            //     forbidClick: true, // 禁用背景点击
            //     duration: 0 // 持续时间，默认是 2000，如果为 0 则持续展示
            // });
            try {
                const { data } = await getHotMovie();
                this.list = data.list;
            } catch (error) {
                this.$toast('请检查网络刷新重试');
            }
        }
    }
};
</script>

<style scoped lang="scss">
.hotMovie {
    .hotMovieItem {
        margin: 15px 0;
        position: relative;
        width: 100%;
        // height: 400px;
        .hotMovieItem-img {
            width: 670px;
            height: 400px;
        }
        .hotMovieItem-mask {
            position: absolute;
            width: 100%;
            height: 100px;
            bottom: 0px;
            line-height: 50px;
            color: black;
            font-weight: 700;
            background-color: rgba(238, 234, 234, 0.5);
            p {
                font-size: 20px;
                margin: 0;
                margin-left: 30px;
                padding: 0;
                text-align: left;
            }
        }
    }

    .like {
        font-size: 30px;
        text-align: left;
        line-height: 60px;
        margin: 0;
        padding: 0;
        text-indent: 1em;
        color: rgba(16, 16, 16, 100);
    }
    /deep/.van-tabs--line .van-tabs__wrap {
        position: unset;
        height: 400px !important;
    }
    /deep/.van-tabs__line {
        position: absolute;
        bottom: 0.15rem;
        left: 0;
        z-index: 1;
        width: 0.4rem;
        height: 0.03rem;
        background-color: transparent !important;
        border-radius: 0.03rem;
    }
    /deep/.van-tabs__nav:nth-child(1) {
        padding-left: 22px !important;
    }
    /deep/.van-tab {
        padding: 0 5px !important;
    }
    /deep/.van-tabs__content {
        display: none !important;
    }
}
</style>
